package MyStack;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created by abhijeet on 17/7/14.
 */
public class Main {

    public static void main(String[] args) {

        Stack myStack = new Stack();
        int choice = 0;
        int data = -1;
        System.out.println("* Stack Operations *");
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        while(choice != 3) {
            System.out.print("\n---MENU---\n<1>Push\n<2>Pop\n<3>Exit");
            try {
                choice = Integer.parseInt(reader.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            switch(choice) {
                case 1 :
                    System.out.println("Enter Data : ");
                    try {
                        data = Integer.parseInt(reader.readLine());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    myStack.push(data);
                    break;

                case 2 :
                    data = myStack.pop();
                    if(data > 0)
                        System.out.println("Data : " + data);
                    break;

                case 3:
                    break;

            }
        }
    }
}
